input	A:5880 X:5880 Y:ffff S:01f8 D:0000 DB:01 NvMxdIzC V:243 H:328 F:33
output 	A:58a0 X:58a0 Y:ffff S:01f8 D:0000 DB:01 NvMxdIzC V:244 H:155 F:34


//replace original subroutine with new check subroutine
80e2ec jml $88841d		[88841d] (5C 1D 84 88) 	//go to unused level text x4041d


//new check subroutine, nested
88841d php						 (08)			//push P in stack
88841e jsl $888432		[88842d] (22 32 84 88)	
888422 beq $842d				 (F0 09)		//subroutine exit, check Z flag status
888424 plp						 (28)			//if false, pop P from stack
888425 jsl $80a020		[80a020] (22 20 A0 80)	//go to original subroutine = return
888429 jml $80e2f0		[80e2f0] (5C F0 E2 80)	//go to original path = end additional check
88842d plp						 (28)			//if true, pop P from stack
88842e jml $80e302		[80e302] (5C 02 E3 80)	//bypass 2nd subroutine = end additional check


//set 16-bit mode
888432 rep #$20					 (C2 20)		//accumulator 16-bit
888434 rep #$10					 (C2 10)		//X-Y index 16-bit
//clear P 
888436 clc						 (18)			//clear carry
888437 rep #$80					 (C2 80)		//clear negative
888439 rep #$02					 (C2 02)		//clear zero


//check if A = "skip" value
88843b cmp #$5880 				 (C9 80 58)		//compare A with output first subroutine
88843e beq $8443				 (F0 03)		//if equal, skip jump and go to check X
888440 jmp				[888451] (4C 62 84)		//if not equal, jump to "2nd subroutine" exit
		
		
//check if X = "skip" value
888443 rep #$02					 (C2 02)		//clear zero
888445 cpx #$5880				 (E0 80 58)		//compare X with output first subroutine
888448 beq						 (F0 03)		//if equal, skip jump and go to check Y
88844a jmp				[888451] (4C 62 84)		//if not equal, jump to "2nd subroutine" exit
		
		
//check if Y = "skip" value
88844d rep #$02					 (C2 02)		//clear zero
88844f cpy #$ffff				 (C0 FF FF)		//compare Y with output first subroutine
888452 beq						 (F0 03)		//if equal, skip jump and go to "bypass" exit
888454 jmp				[888451] (4C 62 84)		//if not equal, jump to "2nd subroutine" exit
		
		
//"skip" value confirmed, write new output values
888457 lda	#$58a0				 (A9 A0 58)		//write custom value to A
88845a ldx	#$58a0				 (A2 A0 58)		//write custom value to X
88845d ldy #$ffff				 (A0 FF FF)		//write custom value to Y
888460 sep #$02					 (E2 02)		//set zero flag
888462 rtl 						 (6B)			//return - jumped to return

	
ROM addresses to be replaced with:
PC 0x0062ec: 	5C 1D 84 88
PC 0x04041d:	22 32 84 88 F0 09 28 22 20 A0 80 5C F0 E2 80 28 5C 02 E3 80 C2 20 C2 10 18 C2 80 C2 02 C9 80 58 F0 03 4C 62 84 C2 02 E0 80 58 F0 03 4C 62 84 C2 02 C0 FF FF F0 03 4C 62 84 A9 A0 58 A2 A0 58 A0 FF FF E2 02 6B